//
//  LPActDetailResouceTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/7/2.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPActDetailResouceTableViewCell.h"

@interface LPActDetailResouceTableViewCell ()
/**  图片  */
@property (strong, nonatomic) UIImageView  *lpImageView;
/**  标题  */
@property (strong, nonatomic) UILabel  *headLine;
/**  时间图片  */
@property (strong, nonatomic) UIImageView  *timeImageVIew;
/**  时间  */
@property (strong, nonatomic) UILabel  *timeLabel;


@end
@implementation LPActDetailResouceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
        UIView *under = [UIView new];
        under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under];
        under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(1);
    }
    return self;
}


#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.headLine];
    
    self.headLine.sd_layout
    .centerYEqualToView(self)
    .leftSpaceToView(self, 20 * [UIScreen zj_screenWScale])
    .heightIs(20 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 35 * [UIScreen zj_screenWScale]);
}


- (void)setModel:(LPActDetailResouceModel *)model{
    _model = model;
    
    self.headLine.attributedText = [UILabel setSpaceForLineWithText:model.NAME lineSpace:5 * [UIScreen zj_screenHScale]];
    if (model.NAMEHEIGHT > 20 * [UIScreen zj_screenHScale]) {
        self.headLine.sd_layout.heightIs(model.NAMEHEIGHT);
        [self.headLine updateLayout];
    }
}



#pragma mark - getter
- (UILabel *)headLine{
    if (!_headLine) {
        _headLine = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _headLine;
}

@end
